Skip to content

fix: symlink only settings.local.json, keep .claude as real directory#27

Merged
dakl merged 2 commits intomainfrom
bug-report
Mar 31, 2026
Merged

fix: symlink only settings.local.json, keep .claude as real directory#27
dakl merged 2 commits intomainfrom
bug-report

Conversation

@dakl
Copy link
Copy Markdown
Owner

@dakl dakl commented Mar 31, 2026

Summary

Fixes git stash failures when Claude Code runs in worktrees by ensuring .claude/ is a real directory that git can track normally.

What Changed

  • Renamed symlinkClaudeDirlinkClaudeSettings for clarity
  • Changed behavior: only symlink settings.local.json instead of the entire .claude/ directory
  • Keep .claude/ as a real directory so git can track files like commands/, settings.json, CLAUDE.md per-branch
  • Added migration logic for existing worktrees with old directory-symlink behavior
  • Updated 6 tests to verify new behavior, added 3 new test cases

Why

The previous approach of symlinking the entire .claude/ directory into worktrees caused git stash to fail or behave unexpectedly. The symlink is a filesystem object that git doesn't understand well in this context.

The new approach shares only what needs sharing (settings.local.json contains tool permissions that should be consistent) while letting git manage the directory structure normally.

Testing

  • All 227 tests pass (including 5 new tests for the refactored code)
  • Tested: untracked .claude/, committed .claude/, migration from old symlink behavior, leaving existing files untouched
  • Build and lint checks pass

Related Issue

Fixes Steve's bug report: "claude struggles with stashing because of the symlinks"

Fixes git stash failures when Claude Code runs in worktrees by ensuring
.claude/ is a real directory that git can track normally.

Changes:
- Rename symlinkClaudeDir → linkClaudeSettings for clarity
- Only symlink settings.local.json (for shared tool permissions)
- Leave .claude/ as real directory (allows git to track files like
  commands/, settings.json, CLAUDE.md per-branch)
- Add migration for old directory-symlink worktrees
- Update tests to verify new behavior

This eliminates git stash errors caused by directory symlinks while
maintaining permission-sharing across worktrees.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dakl dakl merged commit f7988e9 into main Mar 31, 2026
3 checks passed
@dakl dakl deleted the bug-report branch March 31, 2026 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant